home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Tools / ClassAct / Examples / PrintReq / PrintReqExample.c < prev    next >
C/C++ Source or Header  |  2002-03-03  |  16KB  |  520 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <dos/dos.h>
  4. #include <intuition/intuition.h>
  5. #include <intuition/gadgetclass.h>
  6. #include <intuition/imageclass.h>
  7. #include <intuition/icclass.h>
  8. #include <gadgets/listbrowser.h>
  9. #include <images/label.h>
  10. #include <libraries/asl.h>
  11. #include <libraries/gadtools.h>
  12. #include <utility/tagitem.h>
  13. #include <proto/asl.h>
  14. #include <proto/dos.h>
  15. #include <proto/diskfont.h>
  16. #include <proto/exec.h>
  17. #include <proto/gadtools.h>
  18. #include <proto/graphics.h>
  19. #include <proto/icon.h>
  20. #include <proto/intuition.h>
  21. #include <proto/utility.h>
  22. #include <proto/wb.h>
  23. #include <classact.h>
  24. #include <stdio.h>
  25. #include <string.h>
  26.  
  27. enum { GAD_FROM, GAD_TO, GAD_COPIES, GAD_COLLATE };
  28.  
  29. LONG easy_req(struct Window *, char *, char *, char *, ...);
  30. VOID draw_collate(struct Window *, BOOL);
  31.  
  32. /* Image for the no-collate image.
  33.  */
  34. __chip UWORD nocollate_data[450] =
  35. {
  36.     /* Plane 0 */
  37.     0x0003, 0xFFFF, 0xC000, 0x07FF, 0xFF80,
  38.     0x0002, 0x0000, 0x4000, 0x0400, 0x0080,
  39.     0x0002, 0x0002, 0x6000, 0x0400, 0x04C0,
  40.     0x0002, 0x5806, 0x6000, 0x04B0, 0x0CC0,
  41.     0x01FF, 0xFFE2, 0x6003, 0xFFFF, 0xC4C0,
  42.     0x0100, 0x0027, 0x6002, 0x0000, 0x4EC0,
  43.     0x0100, 0x0330, 0x6002, 0x0006, 0x60C0,
  44.     0x012E, 0x00B4, 0x6002, 0x5C01, 0x68C0,
  45.     0xFFFF, 0xF130, 0x61FF, 0xFFE2, 0x60C0,
  46.     0x8000, 0x13B0, 0x6100, 0x0027, 0x60C0,
  47.     0x8001, 0x9830, 0x6100, 0x0330, 0x60C0,
  48.     0x9700, 0x5E30, 0x612E, 0x00BC, 0x60C0,
  49.     0x8000, 0x9830, 0x6100, 0x0130, 0x60C0,
  50.     0x9400, 0x5834, 0x6128, 0x00B0, 0x68C0,
  51.     0x8001, 0x9830, 0x6100, 0x0330, 0x60C0,
  52.     0x8B5F, 0x1830, 0x6116, 0xBE30, 0x60C0,
  53.     0x8000, 0x1830, 0x6100, 0x0030, 0x60C0,
  54.     0x97B6, 0x1E30, 0x612F, 0x6C3C, 0x60C0,
  55.     0x8000, 0x1830, 0x6100, 0x0030, 0x60C0,
  56.     0x8BA8, 0x1830, 0x6117, 0x5030, 0x60C0,
  57.     0x8000, 0x183F, 0xE100, 0x0030, 0x7FC0,
  58.     0x9BF7, 0x183F, 0xE137, 0xEE30, 0x7FC0,
  59.     0x8000, 0x1830, 0x0100, 0x0030, 0x6000,
  60.     0x9400, 0x1830, 0x0128, 0x0030, 0x6000,
  61.     0x8000, 0x1FF0, 0x0100, 0x003F, 0xE000,
  62.     0x9B00, 0x1FF0, 0x0136, 0x003F, 0xE000,
  63.     0x8000, 0x1800, 0x0100, 0x0030, 0x0000,
  64.     0x8000, 0x1800, 0x0100, 0x0030, 0x0000,
  65.     0xFFFF, 0xF800, 0x01FF, 0xFFF0, 0x0000,
  66.     0x3FFF, 0xF800, 0x007F, 0xFFF0, 0x0000,
  67.     /* Plane 1 */
  68.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  69.     0x0001, 0xFFFF, 0x8000, 0x03FF, 0xFF00,
  70.     0x0001, 0xFFFD, 0x8000, 0x03FF, 0xFB00,
  71.     0x0001, 0xDBF9, 0x8000, 0x03B7, 0xF300,
  72.     0x0000, 0x001D, 0x8000, 0x0000, 0x3B00,
  73.     0x00FF, 0xFFD8, 0x8001, 0xFFFF, 0xB100,
  74.     0x00FF, 0xFCCF, 0x8001, 0xFFF9, 0x9F00,
  75.     0x00ED, 0xFF47, 0x8001, 0xDBFE, 0x8F00,
  76.     0x0000, 0x0ECF, 0x8000, 0x001D, 0x9F00,
  77.     0x7FFF, 0xEC47, 0x80FF, 0xFFD8, 0x8F00,
  78.     0x7FFE, 0x67CF, 0x80FF, 0xFCCF, 0x9F00,
  79.     0x76FF, 0xA7CF, 0x80ED, 0xFF4F, 0x9F00,
  80.     0x7FFF, 0x67CF, 0x80FF, 0xFECF, 0x9F00,
  81.     0x77FF, 0xA3C7, 0x80EF, 0xFF47, 0x8F00,
  82.     0x7FFE, 0x67CF, 0x80FF, 0xFCCF, 0x9F00,
  83.     0x6BDF, 0xE7CF, 0x80D7, 0xBFCF, 0x9F00,
  84.     0x7FFF, 0xE7CF, 0x80FF, 0xFFCF, 0x9F00,
  85.     0x76F5, 0xE7CF, 0x80ED, 0xEBCF, 0x9F00,
  86.     0x7FFF, 0xE7CF, 0x80FF, 0xFFCF, 0x9F00,
  87.     0x6BEF, 0xE7CF, 0x80D7, 0xDFCF, 0x9F00,
  88.     0x7FFF, 0xE7C0, 0x00FF, 0xFFCF, 0x8000,
  89.     0x7AF7, 0xE7C0, 0x00F5, 0xEFCF, 0x8000,
  90.     0x7FFF, 0xE7C0, 0x00FF, 0xFFCF, 0x8000,
  91.     0x77FF, 0xE7C0, 0x00EF, 0xFFCF, 0x8000,
  92.     0x7FFF, 0xE000, 0x00FF, 0xFFC0, 0x0000,
  93.     0x7BFF, 0xE000, 0x00F7, 0xFFC0, 0x0000,
  94.     0x7FFF, 0xE000, 0x00FF, 0xFFC0, 0x0000,
  95.     0x7FFF, 0xE000, 0x00FF, 0xFFC0, 0x0000,
  96.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  97.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  98. };
  99.  
  100. struct Image nocollate_image =
  101. {
  102.     0, 0, 74, 30, 2, &nocollate_data[0], 0x3, 0x0, NULL
  103. };
  104.  
  105. /* Image for the no-collate image.
  106.  */
  107. __chip UWORD collate_data[468] =
  108. {
  109.     /* Plane 0 */
  110.     0x01FF, 0xFFE0, 0x07FF, 0xFF80, 0x1FFF, 0xFE00,
  111.     0x0100, 0x0020, 0x0400, 0x0080, 0x1000, 0x0200,
  112.     0x0100, 0x0130, 0x0400, 0x0CC0, 0x1000, 0x3300,
  113.     0x012C, 0x0330, 0x04B0, 0x02C0, 0x12C0, 0x0B00,
  114.     0xFFFF, 0xF133, 0xFFFF, 0xC4CF, 0xFFFF, 0x1300,
  115.     0x8000, 0x13B2, 0x0000, 0x4EC8, 0x0001, 0x0B00,
  116.     0x8000, 0x9832, 0x0006, 0x60C8, 0x0019, 0xB300,
  117.     0x9701, 0x9A32, 0x5C01, 0x68C9, 0x7005, 0xA300,
  118.     0x8000, 0x9832, 0x0002, 0x60C8, 0x0009, 0x8300,
  119.     0x9401, 0xD832, 0x5007, 0x60C9, 0x4005, 0x8300,
  120.     0x8000, 0x1832, 0x0000, 0x60C8, 0x0019, 0x8300,
  121.     0x8B5F, 0x1832, 0x2D7C, 0x60C8, 0xB5F1, 0x8300,
  122.     0x8000, 0x1832, 0x0000, 0x60C8, 0x0001, 0x8300,
  123.     0x97B4, 0x1A32, 0x5ED0, 0x68C9, 0x7B41, 0xA300,
  124.     0x8000, 0x1832, 0x0000, 0x60C8, 0x0001, 0x8300,
  125.     0x8BA8, 0x1832, 0x2EA0, 0x60C8, 0xBA81, 0x8300,
  126.     0x8000, 0x1832, 0x0000, 0x60C8, 0x0001, 0x8300,
  127.     0x9BF7, 0x1832, 0x6FDC, 0x60C9, 0xBF71, 0x8300,
  128.     0x8000, 0x1832, 0x0000, 0x60C8, 0x0001, 0x8300,
  129.     0x9400, 0x1832, 0x5000, 0x60C9, 0x4001, 0x8300,
  130.     0x8000, 0x1FF2, 0x0000, 0x7FC8, 0x0001, 0xFF00,
  131.     0x9B00, 0x1FF2, 0x6C00, 0x7FC9, 0xB001, 0xFF00,
  132.     0x8000, 0x1802, 0x0000, 0x6008, 0x0001, 0x8000,
  133.     0x8000, 0x1802, 0x0000, 0x6008, 0x0001, 0x8000,
  134.     0xFFFF, 0xF803, 0xFFFF, 0xE00F, 0xFFFF, 0x8000,
  135.     0x3FFF, 0xF800, 0xFFFF, 0xE003, 0xFFFF, 0x8000,
  136.     /* Plane 1 */
  137.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  138.     0x00FF, 0xFFC0, 0x03FF, 0xFF00, 0x0FFF, 0xFC00,
  139.     0x00FF, 0xFEC0, 0x03FF, 0xF300, 0x0FFF, 0xCC00,
  140.     0x00ED, 0xFCC0, 0x03B7, 0xFD00, 0x0EDF, 0xF400,
  141.     0x0000, 0x0EC0, 0x0000, 0x3B00, 0x0000, 0xEC00,
  142.     0x7FFF, 0xEC41, 0xFFFF, 0xB107, 0xFFFE, 0xF400,
  143.     0x7FFF, 0x67C1, 0xFFF9, 0x9F07, 0xFFE6, 0x4C00,
  144.     0x76FE, 0x63C1, 0xDBFE, 0x8F07, 0x6FFA, 0x3C00,
  145.     0x7FFF, 0x67C1, 0xFFFD, 0x9F07, 0xFFF6, 0x7C00,
  146.     0x77FE, 0x23C1, 0xDFF8, 0x8F07, 0x7FFA, 0x3C00,
  147.     0x7FFF, 0xE7C1, 0xFFFF, 0x9F07, 0xFFE6, 0x7C00,
  148.     0x6BDF, 0xE7C1, 0xAF7F, 0x9F06, 0xBDFE, 0x7C00,
  149.     0x7FFF, 0xE7C1, 0xFFFF, 0x9F07, 0xFFFE, 0x7C00,
  150.     0x76F5, 0xE3C1, 0xDBD7, 0x8F07, 0x6F5E, 0x3C00,
  151.     0x7FFF, 0xE7C1, 0xFFFF, 0x9F07, 0xFFFE, 0x7C00,
  152.     0x6BEF, 0xE7C1, 0xAFBF, 0x9F06, 0xBEFE, 0x7C00,
  153.     0x7FFF, 0xE7C1, 0xFFFF, 0x9F07, 0xFFFE, 0x7C00,
  154.     0x7AF7, 0xE7C1, 0xEBDF, 0x9F07, 0xAF7E, 0x7C00,
  155.     0x7FFF, 0xE7C1, 0xFFFF, 0x9F07, 0xFFFE, 0x7C00,
  156.     0x77FF, 0xE7C1, 0xDFFF, 0x9F07, 0x7FFE, 0x7C00,
  157.     0x7FFF, 0xE001, 0xFFFF, 0x8007, 0xFFFE, 0x0000,
  158.     0x7BFF, 0xE001, 0xEFFF, 0x8007, 0xBFFE, 0x0000,
  159.     0x7FFF, 0xE001, 0xFFFF, 0x8007, 0xFFFE, 0x0000,
  160.     0x7FFF, 0xE001, 0xFFFF, 0x8007, 0xFFFE, 0x0000,
  161.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  162.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  163. };
  164.  
  165. struct Image collate_image =
  166. {
  167.     0, 0, 88, 26, 2, &collate_data[0], 0x3, 0x0, NULL
  168. };
  169.  
  170. /* Here's where it all starts.
  171.  */
  172. main()
  173. {
  174.     struct Screen *screen = NULL;
  175.  
  176.     if (!ButtonBase) return(20);
  177.  
  178.     /* We'll just open up on the default public screen, and use its screen font.
  179.      */
  180.     if (screen = LockPubScreen(NULL))
  181.     {
  182.         struct DrawInfo *drinfo = GetScreenDrawInfo(screen);
  183.         struct List *radio_list;
  184.         struct Image *l, *collate_limage, *nocollate_limage;
  185.         struct Gadget *collate_gad, *nocollate_gad;
  186.         Object *layout, *collate_layout;
  187.         UWORD mapping[4];
  188.  
  189.         /* Setup a simple mapping.
  190.          */
  191.         mapping[0] = drinfo->dri_Pens[BACKGROUNDPEN];
  192.         mapping[1] = drinfo->dri_Pens[SHADOWPEN];
  193.         mapping[2] = drinfo->dri_Pens[SHINEPEN];
  194.         mapping[3] = drinfo->dri_Pens[FILLPEN];
  195.  
  196.         /* Create radio buttons.
  197.          */
  198.         radio_list = RadioButtons(    "All Pages",
  199.                                     "Odd Pages",
  200.                                     "Even Pages",
  201.                                     "Current Page",
  202.                                     "Range of Pages:",
  203.                                     NULL);
  204.  
  205.         nocollate_limage = LabelObject,
  206.             /* LABEL_Mapping, mapping, */
  207.             LABEL_Image, &nocollate_image,
  208.             LabelEnd;
  209.         collate_limage = LabelObject,
  210.             /* LABEL_Mapping, mapping, */
  211.             LABEL_Image, &collate_image,
  212.             LabelEnd;
  213.  
  214.         if (layout = LayoutObject,
  215.                         GA_DrawInfo, drinfo,
  216.                         LAYOUT_DeferLayout, TRUE,    /* Layout refreshes done on
  217.                                                      * task's context (by the
  218.                                                      * window class) */
  219.                         LAYOUT_SpaceOuter, TRUE,
  220.                         LAYOUT_ShrinkWrap, TRUE,
  221.                         LAYOUT_VertAlignment, LAYOUT_ALIGN_TOP,
  222.                         LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  223.  
  224.                         LAYOUT_AddChild, LayoutObject,
  225.                             LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  226.                             LAYOUT_VertAlignment, LAYOUT_ALIGN_CENTER,
  227.                             LAYOUT_SpaceOuter, TRUE,
  228.  
  229.                             LAYOUT_AddImage, l = LabelObject,
  230.                                 IA_Font, screen->Font,
  231.                                 LABEL_Text, "Driver:",
  232.                                 LabelEnd,
  233.                             CHILD_MinWidth, l->Width,
  234.                             CHILD_MinHeight, l->Height,
  235.                             CHILD_WeightedWidth, 0,
  236.                             CHILD_WeightedHeight, 0,
  237.  
  238.                             LAYOUT_AddChild, ButtonObject,
  239.                                 GA_Text, "EpsonX",
  240.                                 GA_ReadOnly, TRUE,
  241.                                 ButtonEnd,
  242.                             LayoutEnd,
  243.                         CHILD_WeightedHeight, 0,
  244.  
  245.                         LAYOUT_AddChild, LayoutObject,
  246.                             LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  247.  
  248.                             LAYOUT_AddChild, LayoutObject,
  249.                                 LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  250.                                 LAYOUT_SpaceOuter, TRUE,
  251.                                 LAYOUT_BevelStyle, BVS_GROUP,
  252.                                 LAYOUT_Label, "Page Range",
  253.  
  254.                                 LAYOUT_AddChild, RadioButtonObject,
  255.                                     GA_DrawInfo, drinfo,
  256.                                     RADIOBUTTON_Labels, radio_list,
  257.                                     RADIOBUTTON_Spacing, 3,
  258.                                     RadioButtonEnd,
  259.     
  260.                                 LAYOUT_AddChild, LayoutObject,
  261.                                     LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  262.                                     LAYOUT_VertAlignment, LAYOUT_ALIGN_CENTER,
  263.     
  264.                                     LAYOUT_AddImage, l = LabelObject,
  265.                                         IA_Font, screen->Font,
  266.                                         LABEL_Text, "from:",
  267.                                         LabelEnd,
  268.                                     CHILD_MinWidth, l->Width,
  269.                                     CHILD_MinHeight, l->Height,
  270.                                     CHILD_WeightedWidth, 0,
  271.                                     CHILD_WeightedHeight, 0,
  272.     
  273.                                     LAYOUT_AddChild, IntegerObject,
  274.                                         INTEGER_Number, 1,
  275.                                         INTEGER_Minimum, 0,
  276.                                         IntegerEnd,
  277.     
  278.                                     LAYOUT_AddImage, l = LabelObject,
  279.                                         IA_Font, screen->Font,
  280.                                         LABEL_Text, " to:",
  281.                                         LabelEnd,
  282.                                     CHILD_MinWidth, l->Width,
  283.                                     CHILD_MinHeight, l->Height,
  284.                                     CHILD_WeightedWidth, 0,
  285.                                     CHILD_WeightedHeight, 0,
  286.     
  287.                                     LAYOUT_AddChild, IntegerObject,
  288.                                         INTEGER_Number, 1,
  289.                                         INTEGER_Minimum, 0,
  290.                                         IntegerEnd,
  291.     
  292.                                     LayoutEnd,
  293.                                 LayoutEnd,
  294.     
  295.                             LAYOUT_AddChild, LayoutObject,
  296.                                 LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  297.                                 LAYOUT_SpaceOuter, TRUE,
  298.                                 LAYOUT_BevelStyle, BVS_GROUP,
  299.                                 LAYOUT_Label, "Copies",
  300.                                 LAYOUT_VertAlignment, LAYOUT_ALIGN_TOP,
  301.                                 LAYOUT_ShrinkWrap, TRUE,
  302.     
  303.                                 LAYOUT_AddChild, LayoutObject,
  304.                                     LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  305.                                     LAYOUT_VertAlignment, LAYOUT_ALIGN_CENTER,
  306.     
  307.                                     LAYOUT_AddImage, l = LabelObject,
  308.                                         IA_Font, screen->Font,
  309.                                         LABEL_Text, "Number of Copies:",
  310.                                         LabelEnd,
  311.                                     CHILD_MinWidth, l->Width,
  312.                                     CHILD_MinHeight, l->Height,
  313.                                     CHILD_WeightedWidth, 0,
  314.                                     CHILD_WeightedHeight, 0,
  315.     
  316.                                     LAYOUT_AddChild, IntegerObject,
  317.                                         INTEGER_Number, 1,
  318.                                         INTEGER_Minimum, 0,
  319.                                         IntegerEnd,
  320.     
  321.                                     LayoutEnd,
  322.     
  323.                                 LAYOUT_AddChild, LayoutObject,
  324.                                     LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  325.                                     LAYOUT_VertAlignment, LAYOUT_ALIGN_CENTER,
  326.     
  327.                                     LAYOUT_AddChild, CheckBoxObject,
  328.                                         GA_ID, GAD_COLLATE,
  329.                                         GA_Text, "Collate Pages?",
  330.                                         GA_RelVerify, TRUE,
  331.                                         CheckBoxEnd,
  332.                                     CHILD_MinHeight, screen->Font->ta_YSize + 6,
  333.     
  334.                                     LayoutEnd,
  335.     
  336.                                 LAYOUT_AddChild, collate_layout = LayoutObject,
  337.                                     LAYOUT_HorizAlignment, LAYOUT_ALIGN_CENTER,
  338.                                     LAYOUT_AddChild, collate_gad = ButtonObject,
  339.                                         GA_Image, nocollate_limage,
  340.                                         GA_ReadOnly, TRUE,
  341.                                         ButtonEnd,
  342.                                     CHILD_MinWidth, 100,
  343.                                     CHILD_MinHeight, 40,
  344.                                     CHILD_WeightedWidth, 0,
  345.                                     LayoutEnd,
  346.     
  347.                                 LayoutEnd,
  348.                             LayoutEnd,
  349.                         CHILD_WeightedHeight, 0,
  350.  
  351.                         LayoutEnd)
  352.         {
  353.             struct MsgPort *app_port;
  354.             Object *window_obj;
  355.  
  356.             /* Create a message port for App* messages.  This is needed for
  357.              * iconification.  We're being a touch naughty by not checking
  358.              * the return code, but that just means that iconification won't
  359.              * work, nothing really bad will happen.
  360.              */
  361.             app_port = CreateMsgPort();
  362.  
  363.             /* Create the window object.
  364.              */
  365.             if (window_obj = WindowObject,
  366.                                 WA_Left, 0,
  367.                                 WA_Top, screen->Font->ta_YSize + 3,
  368.                                 WA_CustomScreen, screen,
  369.                                 WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW,
  370.                                 WA_Flags, WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET |
  371.                                             WFLG_SIZEGADGET | WFLG_ACTIVATE | WFLG_SMART_REFRESH,
  372.                                 WA_Title, "Print Requester example",
  373.                                 WA_NewLookMenus, TRUE,
  374.                                 WINDOW_ParentGroup, layout,
  375.                                 WINDOW_IconifyGadget, TRUE,
  376.                                 WINDOW_Icon, GetDiskObject("PROGDIR:PrintReq"),
  377.                                 WINDOW_IconTitle, "PrintReq",
  378.                                 WINDOW_AppPort, app_port,
  379.                                 WINDOW_LockHeight, TRUE,
  380.                                 TAG_DONE))
  381.             {
  382.                 struct Window *win;
  383.  
  384.                 /*  Open the window.
  385.                  */
  386.                 if (win = (struct Window *)CA_OpenWindow(window_obj))
  387.                 {
  388.                     ULONG signal;
  389.                     BOOL ok = TRUE, collate = FALSE;
  390.  
  391.                     /* Draw the collate image.
  392.                      */
  393.                     /* draw_collate(win, collate); */
  394.  
  395.                     /* Obtain the window wait signal mask.
  396.                      */
  397.                     GetAttr(WINDOW_SigMask, window_obj, &signal);
  398.  
  399.                     /* Input Event Loop
  400.                      */
  401.                     while (ok)
  402.                     {
  403.                         ULONG result;
  404.  
  405.                         Wait(signal | (1L << app_port->mp_SigBit));
  406.  
  407.                         /* CA_HandleInput() returns the gadget ID of a clicked
  408.                          * gadget, or one of several pre-defined values.  For
  409.                          * this demo, we're only actually interested in a
  410.                          * close window and a couple of gadget clicks.
  411.                          */
  412.                         while ((result = CA_HandleInput(window_obj, NULL)) != WMHI_LASTMSG)
  413.                         {
  414.                             switch(result & WMHI_CLASSMASK)
  415.                             {
  416.                                 case WMHI_CLOSEWINDOW:
  417.                                     ok = FALSE;
  418.                                     break;
  419.  
  420.                                 case WMHI_GADGETUP:
  421.                                     switch (result & WMHI_GADGETMASK)
  422.                                     {
  423.                                         case GAD_COLLATE:
  424.                                             collate = !collate;
  425.                                             if (collate)
  426.                                             {
  427.                                                 SetGadgetAttrs(collate_gad, win, NULL,
  428.                                                     GA_Image, collate_limage,
  429.                                                     TAG_DONE);
  430.                                             }
  431.                                             else
  432.                                             {
  433.                                                 SetGadgetAttrs(collate_gad, win, NULL,
  434.                                                     GA_Image, nocollate_limage,
  435.                                                     TAG_DONE);
  436.                                             }
  437.                                             RethinkLayout(collate_layout, win, NULL, TRUE);
  438.                                             break;
  439.  
  440.                                         default:
  441.                                             break;
  442.                                     }
  443.                                     break;
  444.  
  445.                                 case WMHI_ICONIFY:
  446.                                     if (CA_Iconify(window_obj))
  447.                                         win = NULL;
  448.                                     break;
  449.                              
  450.                                 case WMHI_UNICONIFY:
  451.                                     win = CA_OpenWindow(window_obj);
  452.                                     break;
  453.  
  454.                                 default:
  455.                                     break;
  456.                             }
  457.                         }
  458.                     }
  459.                  }
  460.                 else
  461.                     easy_req(NULL, "PrintReq failed to start\nCouldn't open window", "Quit", "");
  462.  
  463.                 /* Disposing of the window object will also close the
  464.                  * window if it is already opened and it will dispose of
  465.                  * all objects attached to it.
  466.                  */
  467.                 DisposeObject(window_obj);
  468.             }
  469.             else
  470.                 easy_req(NULL, "PrintReq failed to start\nCouldn't create window", "Quit", "");
  471.  
  472.             /* Lose the App* message port.
  473.              */
  474.             if (app_port)
  475.                 DeleteMsgPort(app_port);
  476.         }
  477.         else
  478.             easy_req(NULL, "PrintReq failed to start\nCouldn't create layout", "Quit", "");
  479.  
  480.         /* Get rid of our images.
  481.          */
  482.         if (collate_limage)
  483.             DisposeObject(collate_limage);
  484.         if (nocollate_limage)
  485.             DisposeObject(nocollate_limage);
  486.  
  487.         if (radio_list)
  488.             FreeRadioButtons(radio_list);
  489.  
  490.         if (drinfo)
  491.             FreeScreenDrawInfo(screen, drinfo);
  492.  
  493.         UnlockPubScreen(0, screen);
  494.     }
  495.     else
  496.         easy_req(NULL, "PrintReq failed to start\nCouldn't lock destination screen", "Quit", "");
  497.  
  498.     exit(0);
  499. }
  500.  
  501. /* Do an easy requester.
  502.  */
  503. LONG easy_req(struct Window *win, char *reqtext, char *reqgads, char *reqargs,
  504. ...)
  505. {
  506.     struct EasyStruct general_es =
  507.     {
  508.         sizeof(struct EasyStruct),
  509.         0,
  510.         "SBGen",
  511.         NULL,
  512.         NULL
  513.     };
  514.  
  515.     general_es.es_TextFormat = reqtext;
  516.     general_es.es_GadgetFormat = reqgads;
  517.  
  518.     return(EasyRequestArgs(win, &general_es, NULL, &reqargs));
  519. }
  520.